package com.shujia

object Demo15Apply {
  def main(args: Array[String]): Unit = {
    //创建类的对象
    val per = new Per("张三")

    //调用伴生对象的apply方法创建对象
    val per1: Per = Per("李四")

  }

}

class Per(name: String) {
  val _name: String = name
}

//伴生对象
object Per {
  def apply(name: String): Per = new Per(name)
}
